package util;

import java.util.HashSet;
import java.util.Set;

public class MxSet {
    private String parentId;
    private String symbol;

    public MxSet(String parentId, String symbol) {
        this.parentId = parentId;
        this.symbol = symbol;
    }

    @Override
    public int hashCode() {
        return parentId.hashCode() + symbol.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof MxSet) {
            MxSet o = (MxSet) obj;
            return this.parentId.equals(o.parentId) &&
                    this.symbol.equals(o.symbol);
        } else {
            return false;
        }
    }

    public static void main(String[] args) {
        MxSet set1 = new MxSet("1", "2");
        MxSet set2 = new MxSet("1", "2");

        System.out.println(set1.equals(set2));
        System.out.println(set1 == set2);

        Set<MxSet> set = new HashSet<>();
        set.add(set1);
        set.add(set2);
        System.out.println(set.size());
    }
}
